﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyModels.Models
{
    /// <summary>
    /// 权限表，路由菜单表
    /// </summary>
    public class Permission : RootEntityTKey<long>
    {
        /// <summary>
        /// 上一级菜单（0表示上一级无菜单）
        /// </summary>
        public long Pid { get; set; }

        /// <summary>
        /// 接口 Api
        /// </summary>
        public long Mid { get; set; }

        /// <summary>
        /// 父节点集合
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<long> PidArr { get; set; }

        /// <summary>
        /// 菜单执行Action名
        /// </summary>
        public string? Code { get; set; }

        /// <summary>
        /// 显示菜单名称
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 是否是按钮
        /// </summary>
        public bool IsButton { get; set; } = false;

        /// <summary>
        /// 是否隐藏菜单
        /// </summary>
        public bool? IsHide { get; set; } = false;

        /// <summary>
        /// 是否 KeepAlive
        /// </summary>
        public bool? IsKeepAlive { get; set; } = false;

        /// <summary>
        /// 按钮事件
        /// </summary>
        [SugarColumn(Length =100)]
        public string? Func { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int OrderSort { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        [SugarColumn(Length =100)]
        public string? Icon { get; set; }

        /// <summary>
        /// 菜单描述
        /// </summary>
        [SugarColumn(Length =100)]
        public string? Description { get; set; }

        /// <summary>
        /// 激活状态
        /// </summary>
        public bool Enabled { get; set; }


        [SugarColumn(IsIgnore = true)]
        public List<string> PNameArr { get; set; } = new List<string>();

        [SugarColumn(IsIgnore =true)]
        public List<string> PCodeArr { get; set; } = new List<string>();

        [SugarColumn(IsIgnore =true)]
        public string? MName { get; set; }

        [SugarColumn(IsIgnore = true)]
        public bool HasChildren { get; set; } = true;

        [SugarColumn(IsIgnore = true)]
        public List<Permission> Children { get; set; } = new List<Permission>();

        [SugarColumn(IsIgnore = true)]
        public Modules? Module { get; set; }
    }
}
